class Solution {
public:
    int maxFrequencyElements(vector<int>& nums) {
        int count[101] = { 0 };
        for (int i : nums)
            count[i]++;

        int maxn = 0, maxl = 0;
        for (int i = 1; i <= 100; i++) {
            if (maxn < count[i]) maxl = count[i], maxn = count[i];
            else if (maxn == count[i]) maxl += count[i];
        }
        return maxl;
    }
};